﻿#include <iostream>
#include <string>
#include <assert.h>
/* glad必须先包含，后包含glfw */
#include "glad/glad.h"
#include "glfw/glfw3.h"
#include "checkError.h"
#include "Application.h"

// 声明且实现窗体变化回调
void OnResze(int width, int height)
{
  std::cout << "窗体最新大小：" << width << " " << height << std::endl;
  GL_CALL(glViewport(0, 0, width, height));
}

void OnKey(int key, int scancode,  int action, int mods)
{
  std::cout << "key：" << key << std::endl;
}


int main()
{
  
  if (!app->init(800, 600))
  {
    return -1;
  }

  // 设置窗口回调
  app->setResizeCallback(OnResze);
  app->setKeyboardCallback(OnKey);

  /* 设置opengl视口以及清理颜色 */
  GL_CALL(glViewport(0, 0, 800, 600));
  GL_CALL(glClearColor(0.2f, 0.3f, 0.3f, 1.0f));

  // 3 执行窗体循环
  while (app->update())
  {
    // 执行opengl画布清理操作
    glClear(GL_COLOR_BUFFER_BIT);
  }

  // 4 退出程序前清理
  app->destroy();
  return 0;
}